package demo519;

import java.util.Map;

public class TestMap {public void addEmp(Map<String, Emp> empMap, Emp emp) {
    empMap.put(emp.getNumber(), emp);
}

    public Emp findAllEmpName(Map<String, Emp> empMap, String name) {
        for (Emp emp : empMap.values()) {
            if (emp.getName().equals(name)) {
                return emp;
            }
        }
        return null;
    }

    public void deleteEmp(Map<String, Emp> empMap, String number) {
        empMap.remove(number);
        System.out.println("员工删除成功");
    }

    public Emp findAllEmpNumber(Map<String, Emp> empMap, String number) {
        return empMap.get(number);
    }

    public void updateEmp(Map<String, Emp> empMap, int age, Emp emp) {
        emp.setAge(age);
        empMap.put(emp.getNumber(), emp);
        System.out.println("员工年龄修改成功");
    }
}
